﻿using IBatisNet.DataMapper;
using IBatisNet.DataMapper.Configuration;
using Lyh.Dbdg.Model;

namespace Lyh.Dbdg.DataAccess
{
    public class Mapper
    {
        private static Category category;

        public static Category Category
        {
            get { return category; }
            set { category = value; }
        }
        private static ISqlMapper instance;

        public static ISqlMapper Instance
        {
            get
            {
                if (instance == null) Rebuild();
                return instance;
            }
        }

        public static void Rebuild()
        {
            var builder = new DomSqlMapBuilder();
            instance = builder.Configure(string.Format("{0}\\SqlMap.config", category.ToString()));
        }
    }
}